//
//  YBTransferResultViewController.m
//  Nectar
//
//  Created by famer on 2023/11/12.
//  Copyright © 2023 asance. All rights reserved.
//

#import "YBTransferResultViewController+LayoutConstraints.h"

@interface YBTransferResultViewController ()

@end

@implementation YBTransferResultViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = kWhiteColor;
    
    [self.view addSubview:self.navigationBar];
    [self.view addSubview:self.contentView];
    
    [self.contentView addSubview:self.resultAmountLabel];
    [self.contentView addSubview:self.detailContentView];
    [self.contentView addSubview:self.okButton];

    [self.detailContentView addSubview:self.dateRow];
    [self.detailContentView addSubview:self.statusRow];
    [self.detailContentView addSubview:self.receiverRow];

    [self setLayoutConstraints];
}

- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    [self.navigationController setNavigationBarHidden:YES animated:YES];
    [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent;
    [self.navigationBar resetBarItemState];
}
- (void)viewWillDisappear:(BOOL)animated{
    [super viewWillDisappear:animated];
}
- (void)viewDidAppear:(BOOL)animated{
    [super viewDidAppear:animated];

    self.resultAmountLabel.text = [NSString stringWithFormat:@"%@ %@",self.amount, self.unit];
    self.dateRow.valueLabel.text = self.date;
    self.statusRow.valueLabel.text = @"Processing";
    self.receiverRow.valueLabel.text = self.address;
}

#pragma mark - Private Method
- (void)popViewController{
    [self.navigationController popViewControllerAnimated:YES];
}


#pragma mark Getter Setter
YBViewGetter(contentView, _contentView, kThemeBackground);
YBViewGetter(detailContentView, _detailContentView, [UIColor hexColor:@"FFFFFF"]);

YBLabelGetter(resultAmountLabel, _resultAmountLabel, [UIFont boldSystemFontOfSize:17], @"* USDT" , kThemeBlackColor, NSTextAlignmentCenter);

- (YBEarnDetailRow *)dateRow{
    if(!_dateRow){
        _dateRow = [[YBEarnDetailRow alloc] initWithFrame:CGRectZero];
        _dateRow.titleLabel.text = @"Date";
    }
    return  _dateRow;
}

- (YBEarnDetailRow *)statusRow{
    if(!_statusRow){
        _statusRow = [[YBEarnDetailRow alloc] initWithFrame:CGRectZero];
        _statusRow.titleLabel.text = @"Status";
    }
    return  _statusRow;
}

- (YBEarnDetailRow *)receiverRow{
    if(!_receiverRow){
        _receiverRow = [[YBEarnDetailRow alloc] initWithFrame:CGRectZero];
        _receiverRow.titleLabel.text = @"Receiver";
    }
    return  _receiverRow;
}


- (YBNavigationBar *)navigationBar{
    if(!_navigationBar){
        _navigationBar = [[YBNavigationBar alloc] initWithFrame:CGRectZero];
        _navigationBar.backgroundColor = kWhiteColor;
        [_navigationBar setTitle:@"Tansfer" titleColor:kThemeBlackColor];
        [_navigationBar setLeftBarImage:@"icon_nav_back" forState:UIControlStateNormal];
        __weak __typeof(&*self)weakSelf = self;
        _navigationBar.onLeftBarButtonBlock = ^(){
            __strong __typeof(&*weakSelf)strongSelf = weakSelf;
            if(!strongSelf) return;
            
            [strongSelf.navigationController popViewControllerAnimated:YES];
        };
    }
    return _navigationBar;
}


- (UIButton *)okButton{
    if(!_okButton){
        _okButton = [UIButton buttonWithType:UIButtonTypeCustom];
        _okButton.backgroundColor = kThemeColor;
        _okButton.clipsToBounds = YES;
        _okButton.layer.cornerRadius = 6;
        [_okButton setTitleColor:kWhiteColor forState:UIControlStateNormal];
        [_okButton setTitleColor:kWhiteColor forState:UIControlStateSelected];
        [_okButton setTitle:@"OK" forState:UIControlStateNormal];
        [_okButton setTitle:@"OK" forState:UIControlStateSelected];
        [_okButton addTarget:self action:@selector(popViewController) forControlEvents:UIControlEventTouchUpInside];
    }
    return _okButton;
}
@end
